package org.baicaix.utils {
	import flash.text.TextField;

	/**
	 * @author zjw
	 * 操作文本对象的类
	 */
	public class TextFieldUtils {
		private static var newLinePattern : RegExp = /$/m;

		/**
		 * 显示文本信息,现在暂时只支持一种html，多颜色支持的.
		 * @param txt 文本对象
		 * @param info 字符串
		 * @param color 字的颜色.
		 * 
		 */
		public static function  showInfo(txt : TextField,info : String,color : uint = 0x000033,maxNums : uint = 50,delnums : uint = 10) : void {			txt.htmlText += '<font color=\'#' + color.toString(16) + '\'>' + info + '</font>';
			//trace(txt.numLines);
			if(txt.numLines > maxNums) {
				var obj : Object;
				var totalMessage : String = txt.htmlText;
				newLinePattern.lastIndex = 0;
				for(var i : int = 0;i < delnums; i++) {
					obj = newLinePattern.exec(totalMessage);
					newLinePattern.lastIndex = obj.index;
				}
				txt.htmlText = totalMessage.substr(newLinePattern.lastIndex + 1, totalMessage.length - newLinePattern.lastIndex);
			}
			txt.scrollV = txt.maxScrollV;
		}
	}
}
